package core.attribute.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name="attribute")
public class Attribute implements Serializable
{
	private static final long serialVersionUID = -8767337896773261247L;
	private Long uuid;
	private String name ;
	private Set<AttributeValue> values ;
	private boolean multivalued ;
	
	@Id
	@GeneratedValue
	@Column(name="uuid")
	public Long getUuid() {
		return uuid;
	}
	public void setUuid(Long uuid) {
		this.uuid = uuid;
	}
	@Column(name="name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@ManyToMany(cascade = CascadeType.ALL , fetch = FetchType.EAGER)
	@JoinTable(name = "attribute_attributevalue", joinColumns = {@JoinColumn(name ="attribute_uuid") }, inverseJoinColumns = {@JoinColumn(name="attributevalue_uuid")})
	public Set<AttributeValue> getValues() {
		return values;
	}
	public void setValues(Set<AttributeValue> values) {
		this.values = values;
	}
	@Column(name="multivalued")
	public boolean isMultivalued() {
		return multivalued;
	}
	public void setMultivalued(boolean multivalued) {
		this.multivalued = multivalued;
	}
}
